package com.autonavi.collapse.config;

import com.alibaba.druid.pool.DruidDataSource;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.annotation.PostConstruct;
import javax.sql.DataSource;

@Configuration
public class DataSourceConfig {

    @Value("${task.groupname}")
    private String groupname;

    public static String GROUP;

    @PostConstruct
    public void init() {
        GROUP = this.groupname;
    }

    @ConfigurationProperties(prefix = "task.datasource")
    @Bean("taskDataSource")
    public DataSource createTaskDataSource() {
        return new DruidDataSource();
    }

}
